package com.wgts.wgts.mvp.view.activity.shopkeeper;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;

import com.wgts.wgts.R;
import com.wgts.wgts.base.BaseActivity;
import com.wgts.wgts.control.recycleview.CustomLineaLayoutManager;
import com.wgts.wgts.dagger.ComponentHolder;
import com.wgts.wgts.dagger.component.DaggerAdvancedTaskComponent;
import com.wgts.wgts.dagger.module.AdvancedTaskModule;
import com.wgts.wgts.mvp.presenter.IAdvancedTaskPersenter;
import com.wgts.wgts.mvp.view.IAdvancedTaskView;
import com.wgts.wgts.netmodle.resp.ShopKeepTaskEntity;

import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class AdvancedTaskActivity extends BaseActivity implements IAdvancedTaskView {
    @BindView(R.id.img_back)
    ImageView imgBack;
    @BindView(R.id.recycle_view)
    RecyclerView recycleView;

    private AdvancedTaskAdapter advancedTaskAdapter;

    @Inject
    IAdvancedTaskPersenter persenter;

    @Override
    public void init() {
        DaggerAdvancedTaskComponent
                .builder()
                .advancedTaskModule(new AdvancedTaskModule(this))
                .appComponent(ComponentHolder.getInstance().getAppComponent())
                .build()
                .inject(this);
    }

    @Override
    public void onCreate(Bundle saveInstanceBundle) {
        super.onCreate(saveInstanceBundle);
        setContentView(R.layout.advanced_task_activity);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        persenter.shopKeepTask();
    }

    @Override
    public void taskResult(List<ShopKeepTaskEntity> taskEntityList) {
        CustomLineaLayoutManager linearLayoutManager = new CustomLineaLayoutManager(this);
        recycleView.setLayoutManager(linearLayoutManager);
        advancedTaskAdapter = new AdvancedTaskAdapter(this, taskEntityList);
        recycleView.setAdapter(advancedTaskAdapter);
    }

    @Override
    public void onError(int status, String msg) {

    }

    @OnClick(R.id.img_back)
    public void onViewClicked() {
        finish();
    }
}
